<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <title>Title</title>
</head>
<body>
<div id="app">
  <cpn></cpn>
  <cpn></cpn>
  <cpn></cpn>
</div>
<template id="cpn">
  <div>
    <button type="button" @click="count++">+</button>
    <button type="button" @click="count--">-</button>
    <h3>当前值：{{count}}</h3>
  </div>
</template>
<script src="../js/vue.js"></script>
<script>
  Vue.component('cpn', {
    template: '#cpn',
    // 函数创建新的变量所以data要写成函数的形式，这样每个组件在dom中使用数据是不共享
    data () {
      return {
        count: 0
      }
    }
  })
  const app = new Vue({
    el: '#app',
    data: {
      message: "你好",
    }
  })
</script>
</body>
</html>
